
package com.cqvie.dao;

import javax.annotation.Resource;

import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.stereotype.Repository;

import com.cqvie.model.User;

@Repository("userDao")
public class UserDao {    	//管理员功能
	@Resource
	protected SessionFactory sessionFactory;

	//管理员登录功能
	public boolean isExist(String username,String password) {
		Session session = sessionFactory.getCurrentSession();
		String hql = "from User u  where u.username =? and u.password = ?";
		Query query = session.createQuery(hql);
		query.setString(0,username);
		query.setString(1, password);
		if (query.list().size() >= 1) {
			return true;
		}
			return false;
	}

	
	public boolean add(User user){
		sessionFactory.getCurrentSession().save(user);
		return true;
	}
}
